package com.yuanchu.order.controller;

import com.yuanchu.common.utils.PageResult;
import com.yuanchu.common.utils.R;
import com.yuanchu.order.entity.YoshopRechargeOrderEntity;
import com.yuanchu.order.service.YoshopRechargeOrderService;
import com.yuanchu.order.utils.SecurityUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @version: 1.0
 * @Author: adan
 * @description: 会员充值订单接口
 * @date: 2024-02-19 13:53
 */
@Api(value = "RechargeOrderController", tags = "会员充值订单接口")
@RestController
@RequestMapping("recharge")
public class RechargeOrderController {

    @Resource
    private YoshopRechargeOrderService rechargeOrderService;

    @ApiOperation(value = "/recharge/order/list", tags = "查询用户订单列表")
    @GetMapping("/list")
    public R getRechargeOrderList(@RequestParam Integer page) {
        // 根据dataType和page获取用戶订单列表数据
        Integer userId = SecurityUtil.getUserId();
        PageResult<YoshopRechargeOrderEntity> orderList = rechargeOrderService.queryRechargeOrderList(page, userId);
        Map<String, Object> map = new HashMap<>();
        map.put("list", orderList);
        return R.ok().put("data", map);
    }
}
